// 字典项管理
import axios from "@/request/axios";

// 新增
export function dictDataAdd(params: any) {
  return axios({
    url: "/system/dictData/add",
    method:"POST",
    data: params,
  });
}

// 删除
export function dictDataDel(ids: any) {
  return axios({
    url: "/system/dictData/del",
    method:"POST",
    data: ids,
  });
}

// 修改
export function dictDataEdit(params: any) {
  return axios({
    url: "/system/dictData/edit",
    method:"POST",
    data: params,
  });
}

// 获取详情
export function getDictDataById(id: any) {
  return axios({
    url: "/system/dictData/detail",
    method:"POST",
    data: { id }
  });
}

// 查询（分页）
export function dictDataQuery(params: any) {
  return axios({
    url: "/system/dictData/query",
    method:"POST",
    data: params,
  });
}

// 通过字典类型key获取字典数据列表
export function getDictDataListByTypeKey(key: string) {
  return axios({
    url: "/system/dictData/getListByDictKey",
    method:"POST",
    data: {key},
  });
}

// 通过字典类型key和字典值获取label
export function getDictLabelByTypeKeyAndVal(key: string, value:string = '0') {
  return axios({
    url: "/system/dictData/getLabelByTypeKeyAndVal",
    method:"POST",
    data: {key,value},
  });
}


// 获取所有字典key和字典数据的列表,格式[{dictKey:"XING_BIE",dictDatas:[{label:"男",value:"1"}]}]
export function getDictDataAll() {
  return axios({
    url: "/system/dictData/dictAllData",
    method:"POST",
  });
}